﻿
using AutoMapper;
using Modules;
using PmSoft;
using System.ComponentModel.DataAnnotations;

namespace ManagementApi.Models
{
    /// <summary>
    /// 各应用log4net警告日志
    ///</summary>
    public class Log4netWarningEditForm
    {
        /// <summary>
        ///  
        ///</summary>
        [Display(Name = "")]
        [Required(ErrorMessage = "{0}不能为空")]
        public int Id { get; set; }
        /// <summary>
        /// 应用名称 
        ///</summary>
        [Display(Name = "应用名称")]
        [Required(ErrorMessage = "{0}不能为空")]
        public string AppName { get; set; }
        /// <summary>
        /// 时间 
        ///</summary>
        [Display(Name = "时间")]
        public DateTime? Date { get; set; }
        /// <summary>
        ///  
        ///</summary>
        [Display(Name = "")]
        [Required(ErrorMessage = "{0}不能为空")]
        public string Logger { get; set; }
        /// <summary>
        /// 日志消息 
        ///</summary>
        [Display(Name = "日志消息")]
        [Required(ErrorMessage = "{0}不能为空")]
        public string Message { get; set; }

        #region 扩展字段

        //这里自行增加扩展字段，如 项目名称

        #endregion
    }

    public static class Log4netWarningExtensions
    {
        public static Log4netWarningEditForm AsForm(this Log4netWarning entity)
        {
            Log4netWarningEditForm form = new();
            var mapper = ServiceAccessor.GetService<IMapper>();
            mapper.Map(entity, form);
            #region 这里给扩展字段赋值
            #endregion
            return form;
        }
    }
}
